{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "17a539b0",
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "#灰度图片\n",
    "import cv2\n",
    "from matplotlib import pyplot as plt\n",
    " \n",
    "def gray_image():\n",
    "    path='.\\\\321.jpeg'\n",
    "    #读取图片，以灰度模式\n",
    "    img=cv2.imread(path,cv2.IMREAD_GRAYSCALE)\n",
    "    #显示图片，窗口名为image\n",
    "    cv2.imshow('image',img)\n",
    "    cv2.waitKey(0)\n",
    "    cv2.destroyAllWindows()\n",
    "\n",
    "#     plt.imshow(img, 'gray'),plt.show()\n",
    " \n",
    "if __name__=='__main__':\n",
    "    gray_image()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ba3ece03",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
